//
//  BaseViewController.swift
//  新浪微博
//
//  Created by mac on 15/11/27.
//  Copyright © 2015年 mac. All rights reserved.
//

import UIKit

class BaseViewController: UITableViewController,vistorViewLoginDelegate{
    //添加一个用户是否登录
    var userLogin = UserAccountViewModel().userLogin
    //给basetableview添加方可视图属性
    var vistorloginView: vistorView?
    //loadview 准备视图层次结构,加载视图
    //苹果专门为手写代码准备的方法,一旦实现该方法,sb.xib就自动失效
    //在loadview方法会自动检测视图是否为空,如果为空,会自动调用loadview
    override func loadView() {
        userLogin ?super.loadView() : setVisterView()
        print(userLogin)
//       navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "userWillRegister")
//        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "userWillLogin")
    }
    func setVisterView(){
       vistorloginView = vistorView()
        vistorloginView?.vistorViewDelegation = self
        view = vistorloginView
    }
    
    //实现协议方法
    func userWillRegister() {
        print(__FUNCTION__)
    }
    //实现协议方法
    func userWillLogin() {
        let oauth = OAuthViewController()
        let nav = UINavigationController(rootViewController: oauth)
        presentViewController(nav, animated: true, completion: nil)
        
    }
    override func viewWillLayoutSubviews() {
        super.viewWillLayoutSubviews()
    }
}
